package com.usooft.metaTalent.db.platform;

import com.usooft.framework.core.query.Page;
import com.usooft.framework.web.auth.RequiresPermission;
import com.usooft.metaTalent.core.platform.service.ArticleService;
import com.usooft.metaTalent.core.platform.wrapper.ArticleWrapper;
import com.usooft.metaTalent.db.platform.form.ArticleListForm;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/platform/article")
@RequiredArgsConstructor
public class ArticleController {
    private final ArticleService articleService;

    @GetMapping("/list")
    @RequiresPermission(
            value = "/platform/article/list",
            description = "文章/查询"
    )
    public ResponseEntity<?> list(ArticleListForm form) {
        Page<ArticleWrapper> page = articleService.page(form.buildQuery());
        return ResponseEntity.ok(page);
    }
}
